/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.saar.penguin.give2.server.alert;

import de.saar.penguin.give2.server.BigBrother;
import de.saar.penguin.give2.server.Instruction;
import de.saar.penguin.give2.server.SaarNlgSystem;

/**
 *
 * @author koller
 */
public class EnteredRightRoomAlert extends Alert {
    private final String targetRoom;    
    private boolean custom = false;
    private String customMsg = "";

    public EnteredRightRoomAlert(SaarNlgSystem nlg, String targetRoom) {
        super(nlg);
        this.targetRoom = targetRoom;
    }


    @Override
    public boolean isActivated(BigBrother bb) {
        finished = getCurrentRoom().equals(targetRoom);
        return getCurrentRoom().equals(targetRoom);
    }

    @Override
    public Instruction getInstruction() {
        Instruction instr = nlg.instructionGenerator.createInstruction(nlg.visible);
        if (custom) {
            instr.customInstructionPhrase = customMsg;
        } else {
            instr.instructionPhrase = "You are on the right way. " + instr.instructionPhrase;
        }
        return instr;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final EnteredRightRoomAlert other = (EnteredRightRoomAlert) obj;
        if ((this.targetRoom == null) ? (other.targetRoom != null) : !this.targetRoom.equals(other.targetRoom)) {
            return false;
        }
        if (this.custom != other.custom) {
            return false;
        }
        if ((this.customMsg == null) ? (other.customMsg != null) : !this.customMsg.equals(other.customMsg)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + (this.targetRoom != null ? this.targetRoom.hashCode() : 0);
        hash = 97 * hash + (this.custom ? 1 : 0);
        hash = 97 * hash + (this.customMsg != null ? this.customMsg.hashCode() : 0);
        return hash;
    }


}
